<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>js学习笔记</title>
</head>
<body>
    <script src="./utils/myajax.js">
        //定义myajax，网络请求封装位于utils文件下进行，使用导入即可
        //定义myajax调用 myajax(url,methods,data(可选),timeout(可选),headers(可选),success,fail)
        //改造成为Promise对象
        myajax({
            url:"http://www.baidu.com",
            method:'post',
            data:{
              name:'chy',
              age:18
            },
            timeout:3000,
            success:()=>{
                console.log('调用成功')
            },
            fail:()=>{
                console.log('调用失败，检查错误原因')
            }
        }).then(res => {
           console.log(res) 
        }).catch((err) => {
            console.log(err)
        });
        //axios网络库封装

    </script>
</body>
</html>